﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:ribbon="http://schemas.microsoft.com/winfx/2006/xaml/presentation/ribbon"
		xmlns:primitives="clr-namespace:Microsoft.Windows.Controls.Ribbon.Primitives;assembly=RibbonControlsLibrary"
		xmlns:ext="clr-namespace:Microsoft.Windows.Shell;assembly=Microsoft.Windows.Shell">
	<primitives:RibbonScrollButtonVisibilityConverter x:Key="RibbonScrollButtonVisibilityConverter" />
	<Style x:Key="_repeatButtonStyle" TargetType="{x:Type RepeatButton}">
		<Setter Property="OverridesDefaultStyle" Value="true" />
		<Setter Property="Focusable" Value="false" />
		<Setter Property="Width" Value="14" />
		<Setter Property="Background" Value="{DynamicResource White}" />
		<Setter Property="BorderBrush"
				Value="{Binding RelativeSource={RelativeSource Self}, Path=(ribbon:RibbonControlService.Ribbon).BorderBrush}" />
		<Setter Property="ext:WindowChrome.IsHitTestVisibleInChrome" Value="True" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type RepeatButton}">
					<Border Name="OuterBorder" BorderThickness="1" BorderBrush="{TemplateBinding BorderBrush}"
							Background="{TemplateBinding Background}">
						<Border Name="InnerBorder" Background="#80FFFFFF">
							<Path Name="GlyphPath" HorizontalAlignment="Center" VerticalAlignment="Center"
									Fill="#808080" Data="M 4,0 L 0,3.5 L 4,7" />
						</Border>
					</Border>
					<ControlTemplate.Triggers>
						<Trigger Property="HorizontalContentAlignment" Value="Right">
							<Setter TargetName="GlyphPath" Property="Data" Value="M 0,0 L 4,3.5 L 0,7" />
						</Trigger>
						<MultiDataTrigger>
							<MultiDataTrigger.Conditions>
								<Condition
										Binding="{Binding Path=HighContrast, Source={x:Static ext:SystemParameters2.Current}}"
										Value="False" />
								<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}"
										Value="True" />
							</MultiDataTrigger.Conditions>
							<Setter TargetName="InnerBorder" Property="Background"
									Value="{Binding RelativeSource={RelativeSource Self}, Path=(ribbon:RibbonControlService.Ribbon).MouseOverBackground}" />
						</MultiDataTrigger>
						<MultiDataTrigger>
							<MultiDataTrigger.Conditions>
								<Condition
										Binding="{Binding Path=HighContrast, Source={x:Static ext:SystemParameters2.Current}}"
										Value="False" />
								<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsPressed}"
										Value="True" />
							</MultiDataTrigger.Conditions>
							<Setter TargetName="InnerBorder" Property="Background"
									Value="{Binding RelativeSource={RelativeSource Self}, Path=(ribbon:RibbonControlService.Ribbon).PressedBackground}" />
						</MultiDataTrigger>
						<DataTrigger
								Binding="{Binding Path=HighContrast, Source={x:Static ext:SystemParameters2.Current}}"
								Value="True">
							<Setter TargetName="OuterBorder" Property="CornerRadius" Value="0" />
							<Setter TargetName="OuterBorder" Property="BorderBrush"
									Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}" />
							<Setter TargetName="OuterBorder" Property="Background"
									Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
							<Setter TargetName="InnerBorder" Property="CornerRadius" Value="0" />
							<Setter TargetName="InnerBorder" Property="Background" Value="Transparent" />
							<Setter TargetName="GlyphPath" Property="Fill"
									Value="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" />
						</DataTrigger>
						<MultiDataTrigger>
							<MultiDataTrigger.Conditions>
								<Condition
										Binding="{Binding Path=HighContrast, Source={x:Static ext:SystemParameters2.Current}}"
										Value="True" />
								<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}"
										Value="True" />
							</MultiDataTrigger.Conditions>
							<Setter TargetName="InnerBorder" Property="Background"
									Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
						</MultiDataTrigger>
						<MultiDataTrigger>
							<MultiDataTrigger.Conditions>
								<Condition
										Binding="{Binding Path=HighContrast, Source={x:Static ext:SystemParameters2.Current}}"
										Value="True" />
								<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsPressed}"
										Value="True" />
							</MultiDataTrigger.Conditions>
							<Setter TargetName="OuterBorder" Property="BorderBrush"
									Value="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" />
						</MultiDataTrigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	<Style TargetType="{x:Type ribbon:RibbonTabHeaderItemsControl}">
		<Setter Property="Background" Value="Transparent" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type ribbon:RibbonTabHeaderItemsControl}">
					<Border x:Name="MainBorder" Background="{TemplateBinding Background}">
						<ScrollViewer x:Name="ScrollViewer">
							<ItemsPresenter x:Name="ItemsPresenter" />
							<ScrollViewer.Style>
								<Style TargetType="{x:Type ScrollViewer}" BasedOn="{x:Null}">
									<Setter Property="Focusable" Value="False" />
									<Setter Property="VerticalScrollBarVisibility" Value="Disabled" />
									<Setter Property="HorizontalScrollBarVisibility" Value="Auto" />
									<Setter Property="CanContentScroll" Value="True" />
									<Setter Property="Template">
										<Setter.Value>
											<ControlTemplate TargetType="{x:Type ScrollViewer}">
												<Grid x:Name="Grid" Background="{TemplateBinding Background}">
													<Grid.ColumnDefinitions>
														<ColumnDefinition Width="Auto" />
														<ColumnDefinition Width="*" />
														<ColumnDefinition Width="Auto" />
													</Grid.ColumnDefinitions>
													<ScrollContentPresenter Margin="{TemplateBinding Padding}"
															x:Name="PART_ScrollContentPresenter" Grid.ColumnSpan="3"
															Content="{TemplateBinding Content}"
															ContentTemplate="{TemplateBinding ContentTemplate}"
															CanContentScroll="{TemplateBinding CanContentScroll}" />
													<RepeatButton Style="{StaticResource _repeatButtonStyle}"
															HorizontalContentAlignment="Left" Grid.Column="0"
															Command="{x:Static ScrollBar.LineLeftCommand}"
															CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
															Focusable="false">
														<RepeatButton.Visibility>
															<MultiBinding FallbackValue="Visibility.Collapsed"
																	Converter="{StaticResource RibbonScrollButtonVisibilityConverter}"
																	ConverterParameter="0">
																<Binding
																		RelativeSource="{RelativeSource TemplatedParent}"
																		Path="ComputedHorizontalScrollBarVisibility" />
																<Binding
																		RelativeSource="{RelativeSource TemplatedParent}"
																		Path="HorizontalOffset" />
																<Binding
																		RelativeSource="{RelativeSource TemplatedParent}"
																		Path="ExtentWidth" />
																<Binding
																		RelativeSource="{RelativeSource TemplatedParent}"
																		Path="ViewportWidth" />
															</MultiBinding>
														</RepeatButton.Visibility>
													</RepeatButton>
													<RepeatButton Style="{StaticResource _repeatButtonStyle}"
															HorizontalContentAlignment="Right" Grid.Column="2"
															Command="{x:Static ScrollBar.LineRightCommand}"
															CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
															Focusable="false">
														<RepeatButton.Visibility>
															<MultiBinding FallbackValue="Visibility.Collapsed"
																	Converter="{StaticResource RibbonScrollButtonVisibilityConverter}"
																	ConverterParameter="100">
																<Binding
																		RelativeSource="{RelativeSource TemplatedParent}"
																		Path="ComputedHorizontalScrollBarVisibility" />
																<Binding
																		RelativeSource="{RelativeSource TemplatedParent}"
																		Path="HorizontalOffset" />
																<Binding
																		RelativeSource="{RelativeSource TemplatedParent}"
																		Path="ExtentWidth" />
																<Binding
																		RelativeSource="{RelativeSource TemplatedParent}"
																		Path="ViewportWidth" />
															</MultiBinding>
														</RepeatButton.Visibility>
													</RepeatButton>
												</Grid>
											</ControlTemplate>
										</Setter.Value>
									</Setter>
								</Style>
							</ScrollViewer.Style>
						</ScrollViewer>
					</Border>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
</ResourceDictionary>